package com.zzyl.nursing.controller;

import com.zzyl.nursing.dto.CheckInApplyDto;
import com.zzyl.nursing.vo.CheckInDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.CheckIn;
import com.zzyl.nursing.service.ICheckInService;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 入住控制器
 */
@Api(tags = "入住相关接口")
@RestController
@RequestMapping("/nursing/checkIn")
public class CheckInController extends BaseController {

    @Autowired
    private ICheckInService checkInService;

    @PreAuthorize("@ss.hasPermi('nursing:checkIn:list')")
    @ApiOperation("查询入住列表")
    @GetMapping("/list")
    public TableDataInfo list(@ApiParam("入住对象") CheckIn checkIn) {
        startPage();
        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
        return getDataTable(list);
    }

    @ApiOperation("申请入住")
    @PostMapping("/apply")
    public AjaxResult apply(@ApiParam("入住申请DTO") @RequestBody CheckInApplyDto checkInApplyDto) {
        checkInService.apply(checkInApplyDto);
        return AjaxResult.success();
    }

    @ApiOperation("查询申请入住详情")
    @GetMapping("/detail/{id}")
    public AjaxResult detail(@ApiParam("入住申请详情ID") @PathVariable("id") Long id) {
        CheckInDetailVo checkInDetailVo = checkInService.detail(id);
        return success(checkInDetailVo);
    }
}